// 信息查询
const informationInquiry = document.querySelector('.informationInquiry')
// 选课详细
const courseSelection = document.querySelector('.courseSelection')
// about
const about = document.querySelector('.about')
// 选择
const choose = document.querySelectorAll('.navChoose [class^="choose"] ul')   //主要列表功能
const choose3 = document.querySelector('.choose3')  //about的列表
// 定时器
let timeCord = null

// 初始化按钮
!function () {
  function list(e) {
    return () => {
      clearTimeout(timeCord)
      e.style.display = 'block'
    }
  }

  function close(e) {
    return () => {
      timeCord = setTimeout(() => {
        e.style.display = 'none'
      }, 500)
    }
  }

  // 打开信息查询的列表
  informationInquiry.addEventListener('mouseenter', list(choose[0]))
  informationInquiry.addEventListener('click', list(choose[0]))
  // 离开信息查询延时关闭列表
  informationInquiry.addEventListener('mouseleave', close(choose[0]))
  // 进入列表清除计时器
  choose[0].addEventListener('mouseenter', () => {
    clearTimeout(timeCord)
  })
  // 离开列表延时关闭
  choose[0].addEventListener('mouseleave', close(choose[0]))

  courseSelection.addEventListener('mouseenter', list(choose[1]))
  courseSelection.addEventListener('click', list(choose[1]))
  courseSelection.addEventListener('mouseleave', close(choose[1]))
  choose[1].addEventListener('mouseenter', () => {
    clearTimeout(timeCord)
  })
  choose[1].addEventListener('mouseleave', close(choose[1]))

  about.addEventListener('mouseenter', list(choose3))
  about.addEventListener('click', list(choose3))
  about.addEventListener('mouseleave', close(choose3))
  choose3.addEventListener('mouseenter', () => {
    clearTimeout(timeCord)
  })
  choose3.addEventListener('mouseleave', close(choose3))
}()

